<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增工厂')"/>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-factory-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">工厂名称：</label>
            <div class="col-sm-8">
                <input id="factoryName" name="factoryName" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">仓库：</label>
            <div class="col-sm-8">
                <select id="wareId" name="wareId" class="form-control">
                    <option v-for="ware in wares" :value="ware.wareId" v-cloak>{{ware.wareName}}</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">地址：</label>
            <div class="col-sm-8">
                <input id="addr" name="addr" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">邮箱：</label>
            <div class="col-sm-8">
                <input id="email" name="email" class="form-control" type="text" required>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/factory";

    function submitHandler(){
        if($.validate.form()){
            $.operate.save(prefix + "/add", $('#form-factory-add').serialize());
        }
    };

    var app = new Vue({
        el: '.wrapper',
        data: {
            wares: []
        },
        methods: {
            getWares: function(){
                var that = this;
                $.ajax({
                    cache: true,
                    type: "POST",
                    url: "/system/wareInfo/list",
                    data: {},
                    async: false,
                    error: function(request){
                        $.modal.alertError("系统错误");
                    },
                    success: function(data){
                        that.wares = data.rows;
                    }
                });
            }
        },
        created(){
            this.getWares();
        }
    })
</script>
</body>
</html>